package main;

import main.database.DatabaseMan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

/**
 * 这里的exclude解决mongo、jdbc的autoconfig错误，因为我们自己用代码写了数据库连接方式
 */
@SpringBootApplication(exclude = {MongoAutoConfiguration.class, MongoDataAutoConfiguration.class, DataSourceAutoConfiguration.class})
public class MainApplicationClass extends SpringBootServletInitializer {

    //发布的时候，入口方法在这里
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        Logman.info("------------------- Web application start ------------------");

        Logman.init();
        DatabaseMan.Instance().Init();
        GlobalConfig.Init();

        Logman.info("------------------- Web application init finish ------------------");

        return builder.sources(MainApplicationClass.class);
    }

    //在intellij中，入口方法在这里
    public static void main(String[] args) {
        Logman.info("------------------- Web application start ------------------");

        Logman.init();
        DatabaseMan.Instance().Init();
        GlobalConfig.Init();

        Logman.info("------------------- Web application init finish ------------------");

        SpringApplication.run(MainApplicationClass.class, args);
    }
}
